<?php
/**
 * Created by PhpStorm.
 * User: ZhangYinxian
 * Date: 2016-10-08
 * Time: 21:21
 */

namespace app\index\controller;

use think\Controller;
use think\Db;

class DataAdd extends Controller
{
     public function index(){
         $standards = Db::table('amino_standard')->where('is_basic',1)->select();
         $datas = [];
         foreach ($standards as $standard){
             foreach ($standards as $wrong_standard){
                 $original_single = $standard['single'];
                 $wrong_single = $wrong_standard['single'];

                 $original_residue_weight = $standard['residue_weight'];
                 $wrong_residue_weight = $wrong_standard['residue_weight'];

                 $value = $wrong_residue_weight - $original_residue_weight;
                 if ($value!=0){
                     $data = [
                         'original'=>$original_single,
                         'wrong'=>$wrong_single,
                         'value'=>$value
                     ];

                     array_push($datas, $data);
                 }
             }
         }
         debug('start');
         $result = Db::table('amino_wrong_data')->insertAll($datas);
         debug('end');
         dump($result);
         echo debug('start','end').'s';
     }
}